// JavaScript Document
$().ready(function() { 
	$("#rulesandregulation-node-form").validate({																			 
					rules: {
						'field_rules_dep[und]': { 
							required: true,
							maxlength: 255,
							chkbadchar:true,
							valuenotequals: '_none',
						},
						'field_rules_organisation[und]': { 
							required: true,
							maxlength: 255,
							chkbadchar:true,
							valuenotequals: '_none',
						},
						'title': { 
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
						
						'field_rules_category[und]':{
							multi_dist_select: true,
						},
						'rules_field_actnumber[und][0][value]':{
							minlength: 5,
							maxlength: 255,
							digits : true,
							chkbadchar:true,
							splchar:true,
						},
						'rules_field_rulesyear[und][0][value]':{
							digits : true,
							minlength: 4,
							maxlength: 4,
							min:1640,
							year_not_greater : true,	
						},
						'rules_field_short[und][0][value]':{
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
						'rules_field_titleact[und][0][value]':{
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
						'rules_field_date[und][0][value][date]':{
							dateformat : true,
							date_notless_tdy:true,
						},
						'rules_field_des[und][0][value]':{
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,
						},
										
						'field_rules_avail[und]': { 
							required: true,
							maxlength: 200,
							chkbadchar:true,
						},
						
						'field_rules_url[und][0][value]':{
							required: "#edit-field-rules-avail-und-online-available:checked",
							url: true,
							chkbadchar:true,

						},
						'files[field_rules_fileup_und_0]':{
							required: "#edit-field-rules-avail-und-downloadable:checked",
							chkfile_format_size: true,
						},
						'rules_field_keyword[und][0][value]':{
							required: true,
							minlength: 5,
							maxlength: 255,
							chkbadchar:true,
							splchar:true,							
						},
						
						
						
					
					},
                    messages: {
						'field_rules_dep[und]':{
							required: 'Please Select Concerned Department',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar: 'insert, select, update, delete, drop, alter, change, modify not allowed.',
							valuenotequals: 'Please Select Concerned Department',
							},
							'field_rules_organisation[und]':{
							required: 'Please Select Organization',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar: 'insert, select, update, delete, drop, alter, change, modify not allowed.',	
							valuenotequals: 'Please Select Organisation Name',
							},
							'title': { 
							required:  'Please enter Title',
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',
							},
							'field_rules_category[und]':{
								multi_dist_select: 'Please Select the Category',
							},
							'rules_field_actnumber[und][0][value]':{
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							digits:'Please Enter only Number',	
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',

							},
							'rules_field_rulesyear[und][0][value]':{
							digits:'Please Enter only Year',	
							minlength:'Please Enter valid year',
							maxlength:'Please Enter valid year',
							year_not_greater : 'Year should not be greater than current year',
							},
							'rules_field_short[und][0][value]':{
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',
					
							},
							'rules_field_titleact[und][0][value]':{
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',
					
							},
							'rules_field_date[und][0][value][date]':{
							dateformat: 'Invalid Date format',
							date_notgreater_tdy: 'Commencement Date should not be greater than today date.'
							},
							'rules_field_des[und][0][value]':{
							required:  'Please enter Description',
							minlength: 'Minimum 5 characters should be entered',
							maxlength: 'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',

							},				
							'field_rules_avail[und]': { 
							required: 'Please select Availability Of Rules',
							maxlength:  'Invalid option',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							},
							'field_form_avail[und][0][value]':{
							required: "Please Enter URL",
							url: 'Not Valid URL',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',

							},
							'files[field_form_upload_und_0]':{
							required: 'Please select upload file',
							chkfile_format_size: 'Invalid File Format',
							},
							'field_form_keywords[und][0][value]':{
							required : 'Please Enter Keywords',
							minlength: 'Minimum 5 characters should be entered',
							maxlength:  'Maximum 255 character only allowed',
							chkbadchar:'insert, select, update, delete, drop, alter, change, modify not allowed.',
							splchar:'Special Characters are not allowed',					
							},
	
				}, 
					errorLabelContainer: "#errormsg_container",
					 //focusInvalid: false,
   					invalidHandler: function(form, validator) {
       
       					 if (!validator.numberOfInvalids())
								return;
						else{
							
							  $("#rulesandregulation-node-form").create_errormsg_container('errormsg_container','rulesandregulation-node-form');
						}
							
							$('html, body').animate({
								scrollTop: $(validator.errorList[0].element).offset().top - 100
							}, 1000);
							
						},
										   
	});
});


